<?php
class TPException extends Exception
{
    protected $ret = array();
    // 重定义构造器使 message 变为必须被指定的属性
    public function __construct($ErrCode, $data = array(), $append = array(), $isEng = false)
    {
        $this->ret = retArray($ErrCode, $data, $append);
        if ($ErrCode != ErrCode::ErrCode_00000) {
            log_info($this->getFile() . ":" . $this->getLine());
            log_info($this->getTraceAsString());
        }

        //自定义错误直接返回错误信息
        exit($this->getRetJson());
        // 确保所有变量都被正确赋值
        // parent::__construct(($isEng ? $this->ret[RET_EN_MSG]: $this->ret[RET_MSG]), $this->ret[RET_CODE]);
    }

    final public function getRetArray()
    {
        return $this->ret;
    }

    final public function getRetJson()
    {
        return toRetJson($this->ret);
    }
}
